home *** CD-ROM | disk | FTP | other *** search
/ Suzy B Software 2 / Suzy B Software CD-ROM 2 (1994).iso / extras / falcon / wd2d_pro / sources / convert.s < prev    next >
Text File  |  1995-04-27  |  16KB  |  815 lines

  1. ***************************************************************************
  2. * Sous-module du Wax D2D Pro * Routs Conversions de formats * 02/XII 1994 *
  3. ***************************************************************************
  4.  
  5. conv1:    move.l #'*.TR',whato        ; stéréo -> Mono
  6.     move.w #'K'*256,whato+4
  7.     lea text_mono1,a0
  8.     bsr copy_in2_select
  9.     bsr fileselect
  10.     tst d4
  11.     beq annule11
  12.  
  13.     bsr stop_if_running
  14.  
  15.     file_open read,params_it
  16.     move.w d0,handle1
  17.     bmi annule11
  18.  
  19.     lea text_mono2,a0
  20.     bsr copy_in2_select
  21.     bsr fileselect
  22.     tst d4
  23.     beq annule12
  24.  
  25.     file_open write,params_it
  26.     move.w d0,handle2
  27.     bmi annule12
  28.  
  29. conv_auto1:    move.l #TAILLE_BUFF_TEMP,d0
  30.     bsr allocate_dis_memory
  31.     bmi annule13
  32.     move.l d0,memory_pointer
  33.  
  34. .all_file:    file_read memory_pointer,#TAILLE_BUFF_TEMP/2,handle1
  35.     tst.l d0
  36.     beq.s annule14
  37.  
  38.     lsr.l #1,d0        ; /2
  39.     move.l d0,d7
  40.     lsr.l #1,d0        ; /2 : combien de fois (1.w+1.w)=4 octets ?
  41.  
  42.     move.l memory_pointer,a0
  43.     move.l memory_pointer,a1
  44.     add.l #TAILLE_BUFF_TEMP/2,a1
  45.  
  46. .mono:    move.w (a0)+,d1    ; 4 par 4
  47.     ext.l d1
  48.     move.w (a0)+,d2
  49.     ext.l d2
  50.     add.l d2,d1
  51.     asr.l #1,d1
  52.     move.w d1,(a1)+
  53.     subq.l #1,d0
  54.     bgt.s .mono
  55.  
  56.     move.l memory_pointer,d0
  57.     add.l #TAILLE_BUFF_TEMP/2,d0
  58.     file_write d0,d7,handle2
  59.     cmp.l d7,d0            ; écrit OK ?
  60.     bne.s annule14
  61.     cmp.l #TAILLE_BUFF_TEMP/2/2,d7
  62.     beq.s .all_file
  63.  
  64. annule14:    move.l memory_pointer,d0
  65.     bsr desallocate_dis_memory
  66.  
  67. annule13:    file_close handle2
  68.  
  69. annule12:    file_close handle1
  70.  
  71. annule11:    bra boucle_gem_principale
  72.  
  73.     ; ------------
  74.  
  75. conv2:    move.l #'*.TR',whato        ; Left/Right -> Left + Right
  76.     move.w #'K'*256,whato+4
  77.     lea text_two1,a0
  78.     bsr copy_in2_select
  79.     bsr fileselect
  80.     tst d4
  81.     beq annule21
  82.  
  83.     bsr stop_if_running
  84.  
  85.     file_open read,params_it
  86.     move.w d0,handle1
  87.     bmi annule21
  88.  
  89.     lea text_two2,a0
  90.     bsr copy_in2_select
  91.     bsr fileselect
  92.     tst d4
  93.     beq annule22
  94.  
  95.     file_open write,params_it
  96.     move.w d0,handle2
  97.     bmi annule22
  98.  
  99.     lea text_two3,a0
  100.     bsr copy_in2_select
  101.     bsr fileselect
  102.     tst d4
  103.     beq annule23
  104.  
  105.     file_open write,params_it
  106.     move.w d0,handle3
  107.     bmi annule23
  108.  
  109. conv_auto2:    move.l #TAILLE_BUFF_TEMP,d0
  110.     bsr allocate_dis_memory
  111.     bmi annule24
  112.     move.l d0,memory_pointer
  113.  
  114. .all_file:    file_read memory_pointer,#TAILLE_BUFF_TEMP/2,handle1
  115.     tst.l d0
  116.     beq.s annule25
  117.  
  118.     lsr.l #1,d0        ; /2
  119.     move.l d0,d7
  120.     lsr.l #1,d0        ; /2
  121.  
  122.     move.l memory_pointer,a0
  123.     move.l a0,a1
  124.     add.l #TAILLE_BUFF_TEMP/2,a1
  125.     move.l a0,a2
  126.     add.l #TAILLE_BUFF_TEMP*3/4,a2
  127.  
  128. .mono:    move.w (a0)+,(a1)+    ; 4 par 4
  129.     move.w (a0)+,(a2)+
  130.     subq.l #1,d0
  131.     bgt.s .mono
  132.  
  133.     move.l memory_pointer,d0
  134.     add.l #TAILLE_BUFF_TEMP/2,d0
  135.     file_write d0,d7,handle2
  136.     cmp.l d7,d0            ; écrit OK ?
  137.     bne.s annule25
  138.     move.l memory_pointer,d0
  139.     add.l #TAILLE_BUFF_TEMP*3/4,d0
  140.     file_write d0,d7,handle3
  141.     cmp.l d7,d0            ; écrit OK ?
  142.     bne.s annule25
  143.     cmp.l #TAILLE_BUFF_TEMP/2/2,d7
  144.     beq .all_file
  145.  
  146. annule25:    move.l memory_pointer,d0
  147.     bsr desallocate_dis_memory
  148.  
  149. annule24:    file_close handle3
  150. annule23:    file_close handle2
  151. annule22:    file_close handle1
  152.  
  153. annule21:    bra boucle_gem_principale
  154.  
  155.     ; ------------
  156.  
  157. conv3:    move.l #'*.TR',whato        ; Mono -> Stéréo
  158.     move.w #'K'*256,whato+4
  159.     lea text_stereo1,a0
  160.     bsr copy_in2_select
  161.     bsr fileselect
  162.     tst d4
  163.     beq annule31
  164.  
  165.     bsr stop_if_running
  166.  
  167.     file_open read,params_it
  168.     move.w d0,handle1
  169.     bmi annule31
  170.  
  171.     lea text_stereo2,a0
  172.     bsr copy_in2_select
  173.     bsr fileselect
  174.     tst d4
  175.     beq annule32
  176.  
  177.     file_open write,params_it
  178.     move.w d0,handle2
  179.     bmi annule32
  180.  
  181. conv_auto3:    move.l #TAILLE_BUFF_TEMP,d0
  182.     bsr allocate_dis_memory
  183.     bmi annule33
  184.     move.l d0,memory_pointer
  185.  
  186. .all_file:    file_read memory_pointer,#TAILLE_BUFF_TEMP/2/2,handle1
  187.     tst.l d0
  188.     beq.s annule34
  189.  
  190.     move.l d0,d7
  191.     lsr.l #1,d0        ; /2
  192.     lsl.l #1,d7        ; *2
  193.  
  194.     move.l memory_pointer,a0
  195.     move.l a0,a1
  196.     add.l #TAILLE_BUFF_TEMP/2,a1
  197.  
  198. .mono:    move.w (a0)+,d1    ; 2 par 2
  199.     move.w d1,(a1)+
  200.     move.w d1,(a1)+
  201.     subq.l #1,d0
  202.     bgt.s .mono
  203.  
  204.     move.l memory_pointer,d0
  205.     add.l #TAILLE_BUFF_TEMP/2,d0
  206.     file_write d0,d7,handle2
  207.     cmp.l d7,d0            ; écrit OK ?
  208.     bne.s annule34
  209.     cmp.l #TAILLE_BUFF_TEMP/2,d7
  210.     beq.s .all_file
  211.  
  212. annule34:    move.l memory_pointer,d0
  213.     bsr desallocate_dis_memory
  214.  
  215. annule33:    file_close handle2
  216. annule32:    file_close handle1
  217.  
  218. annule31:    bra boucle_gem_principale
  219.  
  220.         ******* WAX conversions *********
  221.  
  222. treat:    macro        ; don't touch d0 d6 d7
  223.     move.w (a0)+,d1
  224.     ext.l d1
  225.     sub.l \1,d1
  226.     bsr change_delta_in_byte
  227. .\@red:    move.b d1,(a1)+
  228.     move.w (a2,d1.w*2),d2
  229.     ext.l d2
  230.     add.l d2,\1
  231.     cmp.l #32767,\1
  232.     bgt.s .\@trop
  233.     cmp.l #-32768,\1
  234.     bge.s .\@coool
  235.  
  236.     lea -1(a1),a1
  237.     sub.l d2,\1
  238.     addq.w #1,d1
  239.     bra.s .\@red
  240. .\@trop:    lea -1(a1),a1
  241.     sub.l d2,\1
  242.     subq.w #1,d1
  243.     bra.s .\@red
  244. .\@coool:
  245.     endm
  246.  
  247. conv6:    bsr stop_if_running
  248.     move.w #3,type_a_sound    ; Mono Track -> DVS
  249.     bra.s conv6b
  250.  
  251.     ; ------------
  252.  
  253. conv5:    bsr stop_if_running
  254.     move #1,type_a_sound    ; Stereo Track -> DVS
  255.  
  256. conv6b:    move.l #'*.TR',whato
  257.     move.w #'K'*256,whato+4
  258.     lea text_dvsw1,a0
  259.     bsr copy_in2_select
  260.     bsr fileselect
  261.     tst d4
  262.     beq annule561
  263.  
  264.     file_open read,params_it    ; open read
  265.     move.w d0,handle1
  266.     bmi annule561
  267.  
  268.     move.l #'*.DV',whato
  269.     move.w #'S'*256,whato+4
  270.     lea text_dvsw2,a0
  271.     bsr copy_in2_select
  272.     bsr fileselect
  273.     tst d4
  274.     beq annule562
  275.  
  276.     file_open write,params_it    ; open write
  277.     move.w d0,handle2
  278.     bmi annule562
  279.  
  280.     move #ASK_TITLE_NAME,d0
  281.     bsr traite_formulaire
  282.  
  283. conv_auto56:
  284.     ; 2+2+packed data(TAILLE_MAGIC) / read data (2*TAILLE_MAGIC)
  285.     move.l #TAILLE_MAGIC*3+4,d0    ; réserve mémoire
  286.     bsr allocate_dis_memory        ; +2 si mono mais pas grave
  287.     bmi annule564
  288.     move.l d0,memory_pointer
  289.  
  290.     lea write_info_dvw,a0
  291.     move.l #'DVSM',dvs_header(a0)
  292.     move.w #0,dvs_header+4(a0)
  293.  
  294.     move.w #16+8+8+32+32+(4+2+256*2),dvs_length(a0)    ; .w
  295.  
  296.     lea table_cv_freq,a1
  297.     clr d0
  298.     move.b frequency_for_play,d0
  299. .find:    cmp.w 2(a1),d0
  300.     beq.s .found
  301.     lea 8(a1),a1
  302.     bra.s .find
  303. .found:    sub.l #table_cv_freq,a1
  304.     move.l a1,d0
  305.     lsr.l #3,d0
  306.     move.w d0,dvs_freq(a0)
  307.  
  308.     move.b #2,dvs_pack(a0)
  309.     move.b type_a_sound+1,dvs_mode(a0)
  310.  
  311.     move.l memory_pointer,a1
  312.     cmp #1,type_a_sound
  313.     bne.s .mono0
  314.     move.l #TAILLE_MAGIC+4,d0    ; stéréo
  315.     move.l #4,how_many_1st_values
  316.     bra.s .go_on
  317. .mono0:    move.l #TAILLE_MAGIC+2,d0
  318.     move.l #2,how_many_1st_values
  319. .go_on:    add.l d0,a1
  320.     move.l a1,pointer_read_data
  321.     move.l d0,dvs_block_length(a0)
  322.  
  323.     lea 16(a0),a0
  324.  
  325.     move.l #'LPKC',(a0)+
  326.     move.w #8,(a0)+
  327.     move.w #8,(a0)+        ; 8-bit pack code
  328.  
  329.     move.l #'CLCK',(a0)+
  330.     move.w #8,(a0)+
  331.     move.w #0,(a0)+        ; Clock Interne
  332.  
  333.     move.l #'TITL',(a0)+        ; Titre : 4+2+26=32
  334.     move.w #32,(a0)+
  335.     save a0
  336.     move.w #ASK_TITLE_NAME,d0
  337.     lea add_tree,a0
  338.     bsr get_addr_tree
  339.     move.l add_tree,a0
  340.     move.w #ASKED_TITLE,d0
  341.     bsr get_text_add
  342.     load a0
  343.     move #26-1,d0
  344. .rcp1:    move.b (a1)+,(a0)+
  345.     dbf d0,.rcp1
  346.  
  347.     move.l #'AUTH',(a0)+        ; Author : 4+2+26=32
  348.     move.w #32,(a0)+
  349.     save a0
  350.     move.w #ASK_TITLE_NAME,d0
  351.     lea add_tree,a0
  352.     bsr get_addr_tree
  353.     move.l add_tree,a0
  354.     move.w #ASKED_AUTHOR,d0
  355.     bsr get_text_add
  356.     load a0
  357.     move #26-1,d0
  358. .rcp2:    move.b (a1)+,(a0)+
  359.     dbf d0,.rcp2
  360.  
  361.     move.l #'PACK',(a0)+
  362.     move.w #4+2+256*2,(a0)+
  363.  
  364.     sub.l #write_info_dvw,a0
  365.     save a0
  366.     file_write #write_info_dvw,a0,handle2
  367.     load a0
  368.     cmp.l d0,a0            ; 16+8+8+32+32+4+2
  369.     bne annule564
  370.  
  371.     file_write #table_dvswax,#256*2,handle2
  372.     cmp.l #256*2,d0
  373.     bne annule564
  374.  
  375. boucle_pack:
  376.     move.w  #-1,-(sp)    ; Shift_Droit:1, SG:2 CTRL:4 ALT:8
  377.     appel bios,11,4    ; état des touches spéciales
  378.     and.w #3,d0
  379.     cmp.w #3,d0
  380.     beq annule564    ; d6 d7 INTACTS
  381.  
  382.     clr d0
  383.     bset #EVNT_MESAG,d0
  384.     bset #EVNT_TIMER,d0
  385.     move #1,d1            ; timer en ms
  386.     bsr traite_evenement_gem
  387.  
  388.     btst #EVNT_MESAG,d0
  389.     beq.s .no_message
  390.  
  391.     neg d1
  392.     cmp.w #ACC_CLOSE,d1        ; ACC_CLOSE
  393.     beq annule564
  394.     cmp.w #AP_TERM,d1        ; AP_TERM
  395.     beq fin
  396.  
  397. .no_message:file_read #read_first_values,how_many_1st_values,handle1
  398.     cmp.l how_many_1st_values,d0
  399.     bne annule564
  400.  
  401.     move.l #(TAILLE_MAGIC+4)/4-1,d0    ; réserve mémoire
  402.     move.l memory_pointer,a0
  403. .clr:    clr.l (a0)+
  404.     dbf d0,.clr
  405.  
  406.     move.l memory_pointer,a0
  407.     move.w read_first_values,d6
  408.     move.w d6,(a0)+
  409.     ext.l d6
  410.     cmp.l #4,how_many_1st_values
  411.     bne.s .mono1
  412.     move.w read_first_values+2,d7
  413.     move.w d7,(a0)+
  414.     ext.l d7
  415. .mono1:
  416.  
  417.     save a0
  418.     file_read pointer_read_data,#TAILLE_MAGIC*2,handle1
  419.     load a1
  420.     move.l d0,d5
  421.     beq annule565        ; écrit les 2 ou 4 -> sort
  422.     move.l pointer_read_data,a0    ; a1 pointe sur destination
  423.     lea table_dvswax+128*2,a2
  424.  
  425.     cmp.l #4,how_many_1st_values
  426.     bne.s .mono2
  427.  
  428. .stereo2:    treat d6
  429.     treat d7
  430.     subq.l #4,d0    ; si mono et non multiple de 4 : bug
  431.     bgt.s .stereo2
  432.     bra.s .finis
  433.  
  434. .mono2:    treat d6
  435.     subq.l #2,d0
  436.     bgt.s .mono2
  437. .finis:
  438.  
  439. annule565:    lsr.l #1,d5
  440.     add.l how_many_1st_values,d5
  441.     save d5
  442.     file_write memory_pointer,d5,handle2
  443.     load d1
  444.     cmp.l d0,d1
  445.     bne.s annule564        ; plus de place sur disque
  446.     move.l #TAILLE_MAGIC,d0
  447.     add.l how_many_1st_values,d0
  448.     cmp.l d0,d1
  449.     beq boucle_pack        ; fin du fichier en lecture
  450.  
  451. annule564:    move.l memory_pointer,d0
  452.     bsr desallocate_dis_memory
  453.  
  454. annule563:    file_close handle2
  455. annule562:    file_close handle1
  456.  
  457. annule561:    bra boucle_gem_principale
  458.  
  459.  BSS
  460. write_info_dvw:    ds.b 16+8+8+32+32+4+2
  461. read_first_values:    ds.w 2
  462. how_many_1st_values:    ds.l 1
  463. type_a_sound:    ds.w 1
  464. pointer_read_data:    ds.l 1    ; pointe sur l'endroit ou charger les datas à packer
  465.  TEXT
  466.  
  467. change_delta_in_byte:
  468.     cmp.l #32767,d1
  469.     bge.s .sup
  470.     cmp.l #-32768,d1
  471.     ble.s .inf
  472.  
  473.     tst.l d1            ; dichotomie de rang 2
  474.     ble.s .inf0
  475.     move.w table_dvswax+128*2+64*2,d2
  476.     ext.l d2
  477.     cmp.l d2,d1
  478.     ble.s .34
  479. .44:    lea table_dvswax+128*2+64*2,a3
  480.     bra.s .zap
  481. .34:    lea table_dvswax+128*2,a3
  482.     bra.s .zap
  483. .inf0:    move.w table_dvswax+64*2,d2
  484.     ext.l d2
  485.     cmp.l d2,d1
  486.     ble.s .14
  487. .24    lea table_dvswax+64*2,a3
  488.     bra.s .zap
  489. .14    lea table_dvswax,a3
  490. .zap:
  491.  
  492. .sear:    lea 2(a3),a3
  493.     move (a3),d2        ; (a3) ; la 2ème valeur
  494.     ext.l d2
  495.     cmp.l d2,d1
  496.     bgt.s .sear
  497.     beq.s .ok
  498.  
  499.     move.w -2(a3),d3
  500.     ext.l d3
  501.     neg.l d3
  502.     add.l d1,d3            ; gauche à milieu
  503.  
  504.     move.l d2,d4        ; milieu à droite
  505.     sub.l d1,d4
  506.  
  507.     cmp.l d3,d4
  508.     ble.s .peti    
  509.     lea -2(a3),a3
  510. .peti:
  511. .ok:    sub.l #table_dvswax,a3
  512.     move.w a3,d1
  513.     asr.w #1,d1
  514.     add.w #-128,d1
  515.     rts
  516. .sup:    move.w #127,d1
  517.     rts
  518. .inf:    move.w #-128,d1
  519.     rts
  520.  
  521.     ; ------------
  522.  
  523. conv7:    move.l #'*.DV',whato        ; DVSW -> Track
  524.     move.w #'S'*256,whato+4
  525.     lea text_dvsw3,a0
  526.     bsr copy_in2_select
  527.     bsr fileselect
  528.     tst d4
  529.     beq annule71
  530.  
  531.     bsr stop_if_running
  532.  
  533.     file_open read,params_it
  534.     move.w d0,handle1
  535.     bmi annule71
  536.  
  537.     move.l #'*.TR',whato
  538.     move.w #'K'*256,whato+4
  539.     lea text_dvsw4,a0
  540.     bsr copy_in2_select
  541.     bsr fileselect
  542.     tst d4
  543.     beq annule72
  544.  
  545.     file_open write,params_it
  546.     move.w d0,handle2
  547.     bmi annule72
  548.  
  549. conv_auto7:    file_read #read_dvs_header,#16,handle1
  550.     cmp.l #16,d0
  551.     bne annule73
  552.  
  553.     lea read_dvs_header,a0
  554.  
  555.     cmp.l #'DVSM',dvs_header(a0)
  556.     bne annule73
  557.     tst.w dvs_header+4(a0)
  558.     bne annule73
  559.     move.w dvs_length(a0),length_2_zap+2
  560.     move.w dvs_freq(a0),frequency_dvs
  561.     cmp.b #2,dvs_pack(a0)        ; 2=packé
  562.     bne annule73
  563.  
  564.     move.b dvs_mode(a0),d0
  565.     cmp.b #1,d0
  566.     bne.s .pas_st
  567.     move.l #4,hmany_1st_bytes
  568.     bra.s .cont
  569. .pas_st:    cmp.b #3,d0
  570.     bne annule73
  571.     move.l #2,hmany_1st_bytes    ; mono
  572. .cont:
  573.     move.l dvs_block_length(a0),which_blk_length
  574.  
  575.     lea table_dvsm,a0    ; table DVSM par défaut
  576.     lea table_depack,a1
  577.     move #256-1,d0
  578. .copy:    move.w (a0)+,(a1)+
  579.     dbf d0,.copy
  580.  
  581.     move.l #16,d7
  582.  
  583. .view_cookies:
  584.     file_read #read_dvs_header,#6,handle1
  585.     cmp.l #6,d0
  586.     bne annule73
  587.  
  588.     lea read_dvs_header,a0
  589.  
  590.     cmp.l #'LPKC',cookie_identify(a0)
  591.     beq.s .lpck
  592.     cmp.l #'PACK',cookie_identify(a0)
  593.     beq.s .pack
  594.  
  595.     clr.l d0
  596.     move.w cookie_length(a0),d0
  597.     add.w d0,d7
  598.     subq.l #6,d0
  599.     file_seek #1,handle1,d0
  600.  
  601. .finish_cookie:
  602.     cmp.l length_2_zap,d7
  603.     bne.s .view_cookies
  604.     bra.s .fincookies
  605.  
  606. .lpck:    file_read #read_dvs_header,#2,handle1
  607.     cmp.l #2,d0
  608.     bne annule73
  609.     add.l #8,d7
  610.     cmp.w #8,read_dvs_header    ; 8 bit pack-code
  611.     beq.s .finish_cookie
  612.     bra annule73
  613.  
  614. .pack:    file_read #table_depack,#256*2,handle1
  615.     cmp.l #256*2,d0
  616.     bne annule73
  617.     add.l #4+2+256*2,d7
  618.     bra.s .finish_cookie
  619.  
  620. .fincookies:file_seek #0,handle1,length_2_zap    ; pour être sur
  621.  
  622.     move.l which_blk_length,d0
  623.     mulu.l #3,d0        ; petite approximation
  624.     bsr allocate_dis_memory        ; +2 si mono mais pas grave
  625.     bmi annule73
  626.     move.l d0,memory_pointer
  627.     add.l which_blk_length,d0
  628.     move.l d0,ad_pointeur_depack
  629.  
  630. depack_routine:
  631.     file_read memory_pointer,which_blk_length,handle1
  632.     move.l d0,d5
  633.     beq annule74
  634.  
  635.     move.l memory_pointer,a0
  636.     move.l ad_pointeur_depack,a1
  637.     lea table_depack+128*2,a2
  638.     move.w (a0)+,d6
  639.     move.w d6,(a1)+
  640.     sub.l #2,d5
  641.     cmp.l #4,hmany_1st_bytes
  642.     bne.s .mono1
  643.  
  644.     move.w (a0)+,d7        ; depack stéréo
  645.     move.w d7,(a1)+
  646.     sub.l #2,d5
  647.     beq.s annule75
  648.  
  649.     move.l d5,d0
  650.  
  651. .dpck_ste:    move.b (a0)+,d1
  652.     ext.w d1
  653.     add.w (a2,d1.w*2),d6
  654.     move.w d6,(a1)+
  655.  
  656.     move.b (a0)+,d1
  657.     ext.w d1
  658.     add.w (a2,d1.w*2),d7
  659.     move.w d7,(a1)+
  660.  
  661.     subq.l #2,d0
  662.     bgt.s .dpck_ste
  663.     bra.s .finis
  664.  
  665. .mono1:    move.l d5,d0
  666.     beq.s annule75
  667.  
  668. .dpck_mono:    move.b (a0)+,d1
  669.     ext.w d1
  670.     add.w (a2,d1.w*2),d6
  671.     move.w d6,(a1)+
  672.  
  673.     subq.l #1,d0
  674.     bgt.s .dpck_mono
  675. .finis:
  676.  
  677. annule75:    lsl.l #1,d5
  678.     add.l hmany_1st_bytes,d5
  679.     save d5
  680.     file_write ad_pointeur_depack,d5,handle2
  681.     load d1
  682.     cmp.l d0,d1            ; écrit OK ?
  683.     bne.s annule74
  684.     move.l which_blk_length,d1
  685.     sub.l hmany_1st_bytes,d1
  686.     lsl.l #1,d1
  687.     add.l hmany_1st_bytes,d1
  688.     cmp.l d0,d1
  689.     beq depack_routine
  690.  
  691. annule74:    move.l memory_pointer,d0
  692.     bsr desallocate_dis_memory
  693.  
  694. annule73:    file_close handle2
  695. annule72:    file_close handle1
  696.  
  697. annule71:    bra boucle_gem_principale
  698.  
  699.  BSS
  700. ad_pointeur_depack:    ds.l 1
  701. hmany_1st_bytes:    ds.l 1    ; 2=mono, 4=stereo
  702. length_2_zap:    ds.l 1
  703. which_blk_length:    ds.l 1
  704. frequency_dvs:    ds.w 1
  705. read_dvs_header:    ds.b 16
  706. table_depack:    ds.w 256
  707.  TEXT
  708.     ; ------------
  709.  
  710. conv8:    move.l #'*.AV',whato        ; AVR -> Track
  711.     move.w #'R'*256,whato+4
  712.     lea text_avr1,a0
  713.     bsr copy_in2_select
  714.     bsr fileselect
  715.     tst d4
  716.     beq annule81
  717.  
  718.     bsr stop_if_running
  719.  
  720.     file_open read,params_it
  721.     move.w d0,handle1
  722.     bmi annule81
  723.  
  724.     move.l #'*.TR',whato
  725.     move.w #'K'*256,whato+4
  726.     lea text_avr2,a0
  727.     bsr copy_in2_select
  728.     bsr fileselect
  729.     tst d4
  730.     beq annule82
  731.  
  732.     file_open write,params_it
  733.     move.w d0,handle2
  734.     bmi annule82
  735.  
  736. conv_auto8:    move.l #TAILLE_BUFF_TEMP*3,d0
  737.     bsr allocate_dis_memory
  738.     bmi annule83
  739.  
  740.     move.l d0,memory_pointer
  741.  
  742.     file_read #read_avr_header,#128,handle1
  743.     cmp.l #128,d0
  744.     bne annule84
  745.  
  746.     lea read_avr_header,a0
  747.  
  748.     cmp.l #'2BIT',(a0)        ; offset : 0
  749.     bne annule84
  750.  
  751.     move.w 12(a0),d5        ; 0=mono,1=stéréo (sert à rien)
  752.     move.w 14(a0),d6        ; 8,12,16 bits
  753.     move.w 16(a0),d7        ; 0=non signé, 1=signé
  754.     move.l #16,d4
  755.     sub.w d6,d4            ; nombre de décalages à faire
  756.  
  757. .redo:    save d4-d7
  758.     file_read memory_pointer,#TAILLE_BUFF_TEMP,handle1
  759.     load d4-d7
  760.     move.l d0,d3
  761.     beq annule84
  762.     move.l d0,d2
  763.  
  764.     move.l memory_pointer,a0
  765.     move.l a0,a1
  766.     add.l #TAILLE_BUFF_TEMP,a1
  767.  
  768.     cmp.w #8,d6
  769.     ble.s .less8
  770.  
  771. .redo1:    move.w (a0)+,d1
  772.     lsl.w d4,d1
  773.     tst d7
  774.     bmi.s .signe1
  775.     sub.w #16384,d1
  776. .signe1:    move.w d1,(a1)+
  777.     sub.l #2,d0
  778.     bne.s .redo1
  779.     bra.s .sauve
  780.  
  781. .less8:    lsl.l #1,d3
  782.  
  783. .redo2:    move.b (a0)+,d1
  784.     lsl.w d4,d1
  785.     tst d7
  786.     bmi.s .signe2
  787.     sub.w #16384,d1
  788. .signe2:    move.w d1,(a1)+
  789.     sub.l #1,d0
  790.     bne.s .redo2
  791.  
  792. .sauve:    move.l memory_pointer,a0
  793.     add.l #TAILLE_BUFF_TEMP,a0
  794.     save d2-d7
  795.     file_write a0,d3,handle2
  796.     load d2-d7
  797.  
  798.     cmp.l d3,d0            ; écrit ce qui se devait ?
  799.     bne.s annule84
  800.  
  801.     cmp.l #TAILLE_BUFF_TEMP,d2    ; fin fichier ?
  802.     beq .redo
  803.  
  804. annule84:    move.l memory_pointer,d0
  805.     bsr desallocate_dis_memory
  806.  
  807. annule83:    file_close handle2
  808. annule82:    file_close handle1
  809.  
  810. annule81:    bra boucle_gem_principale
  811.  
  812.  BSS
  813. read_avr_header:    ds.b 128
  814.  TEXT
  815.